﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;

public partial class AdminTK_BCTonKhoChiTiet : System.Web.UI.Page
{
    protected void checkAlreadyLogin()
    {
        if (Session["UserID"].ToString() == null)//Session["UserType"].ToString() != "QuanTri" ||
        {
            Response.Redirect("Login.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            checkAlreadyLogin();
            LoadRePort();
        }
    }
    public void LoadRePort()
    {
        DateTime tungay = new DateTime();
        DateTime denngay = new DateTime();

        try
        {
            tungay = DateTime.ParseExact(Request["tungay"], "dd/MM/yyyy", null);
            denngay = DateTime.ParseExact(Request["denngay"], "dd/MM/yyyy", null);
        }
        catch
        {
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert",
            //       "alert('Đường dẫn bị sai!Yêu cầu nhập lại');", true);
            Response.Redirect("NotFound.aspx");
        }
        ReportDocument crystalReport = new ReportDocument();
        crystalReport.Load(Server.MapPath("~/Admin/TonKhoChiTiet.rpt"));
        crystalReport.SetDatabaseLogon("sa", "123", @"NHI-PC\SQLEXPRESS", "DBTGBe");

        crystalReport.Refresh();

        crystalReport.SetParameterValue("@tungay", tungay.ToString("MM/dd/yyyy"));
        crystalReport.SetParameterValue("@denngay", denngay.ToString("MM/dd/yyyy"));

        rpTonKho.ReportSource = crystalReport;
    }


}